package com.zhuojy.equity.mall.admin.service.salary;/**
 * @description: TODO
 * @author chen
 * @date 2024/4/6 19:05
 * @version 1.0
 */

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.bo.salary.PayrollItemsBO;
import com.zhuojy.equity.mall.admin.common.entity.po.salary.PayrollItemsPO;
import com.zhuojy.equity.mall.admin.dal.mapper.salary.PayrollItemsMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: TODO
 * @author chen
 * @date 2024/4/6 19:05
 * @version 1.0
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class PayrollItemsService extends ServiceImpl<PayrollItemsMapper, PayrollItemsPO> {
    public Map getPayrollItemsList(PayrollItemsBO payrollItemsBO) {
        IPage<PayrollItemsPO> page = new Page(payrollItemsBO.getCurrentPage(),payrollItemsBO.getPageSize());

        LambdaQueryWrapper<PayrollItemsPO> lqw = Wrappers.lambdaQuery(PayrollItemsPO.class);

        if(StringUtils.isNotEmpty(payrollItemsBO.getProjectName())){
            lqw.like(PayrollItemsPO::getProjectName,payrollItemsBO.getProjectName());
        }
        page = page(page,lqw);

        Map map = new HashMap();
        map.put("rows",page.getRecords());
        map.put("total",page.getTotal());

        return map;
    }

    public PayrollItemsPO findPayrollItems(Long id) {
        PayrollItemsPO one = getOne(Wrappers.lambdaQuery(PayrollItemsPO.class).eq(PayrollItemsPO::getId, id));
        return one;
    }
}
